package cn.edu.kzjsxy.graduationproject.service.impl;

import cn.edu.kzjsxy.graduationproject.common.Page;
import cn.edu.kzjsxy.graduationproject.common.Result;
import cn.edu.kzjsxy.graduationproject.entity.StudentAbsences;
import cn.edu.kzjsxy.graduationproject.entity.StudentDormAssignments;
import cn.edu.kzjsxy.graduationproject.mapper.StudentAbsencesMapper;
import cn.edu.kzjsxy.graduationproject.service.IStudentAbsencesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 学生缺勤记录表 服务实现类
 * </p>
 *
 * @author chén jiā jùn
 * @since 2024-04-14
 */
@Service
public class StudentAbsencesServiceImpl extends ServiceImpl<StudentAbsencesMapper, StudentAbsences> implements IStudentAbsencesService {

	@Autowired
	StudentAbsencesMapper studentAbsencesMapper;

//	根据条件查询学生缺勤记录
	@Override
	public List<StudentAbsences> selectStudentAbsencesByCondition(StudentAbsences studentAbsences) {
		List<StudentAbsences> studentAbsencesList = studentAbsencesMapper.selectStudentAbsencesByCondition(studentAbsences);
		return studentAbsencesList;
	}


// 分页获取学生缺勤记录
	@Override
	public Result<PageInfo<StudentAbsences>> selectStudentAbsencesByPage(Page page, StudentAbsences studentAbsences) {
		// 设置分页
		PageHelper.startPage(page.getPageNum(), page.getPageSize());
		// 执行查询
		List<StudentAbsences> studentAbsencesList = studentAbsencesMapper.selectStudentAbsencesByCondition(studentAbsences);
		PageInfo<StudentAbsences> pageInfo = new PageInfo<>(studentAbsencesList);
		return Result.success(pageInfo);
	}
}
